<div class="layui-input-block" id="tags">
    <blockquote class="layui-elem-quote layui-quote-nm">
    <div class="layui-inline">
        <button type="button" class="layui-btn layui-btn-normal" style="background-color: #{:randColor()};">替换:所属大类</button>
    </div>
    <div class="layui-inline">
        <button type="button" class="layui-btn layui-btn-normal" style="background-color: #{:randColor()};">替换:所属小类</button>
    </div>
    <div class="layui-inline">
        <button type="button" class="layui-btn layui-btn-normal" style="background-color: #{:randColor()};">替换:项目名称</button>
    </div>
    <div class="layui-inline">
        <button type="button" class="layui-btn layui-btn-normal" style="background-color: #{:randColor()};">替换:公司名称</button>
    </div>
    <div class="layui-inline">
        <button type="button" class="layui-btn layui-btn-normal" style="background-color: #{:randColor()};">替换:公司成立时间</button>
    </div>
    <div class="layui-inline">
        <button type="button" class="layui-btn layui-btn-normal" style="background-color: #{:randColor()};">替换:公司地址</button>
    </div>
    <div class="layui-inline">
        <button type="button" class="layui-btn layui-btn-normal" style="background-color: #{:randColor()};">替换:关键词</button>
    </div>
    </blockquote>
</div>
<!--编辑器-->
<script>
    var tags = $('#tags').find('button');
    $.each(tags,function(index,item){
        $(item).click(function(){
            var str = '['+$(this).text()+']';
            addExpressContent(str)
        });
    });

    function addExpressContent(str){
        var obj = document.getElementById("content");
        if (document.selection) {  
            var sel = document.selection.createRange();  
            sel.text = str;  
        } else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {  
            var startPos = obj.selectionStart;  
            var endPos = obj.selectionEnd;  
            var cursorPos = startPos;  
            var tmpStr = obj.value;  
            obj.value = tmpStr.substring(0, startPos) + str + tmpStr.substring(endPos, tmpStr.length);  
            cursorPos += str.length;  
            obj.selectionStart = obj.selectionEnd = cursorPos;  
        } else {  
            obj.value += str;  
        }  
    }
</script>